import { observable, action } from 'mobx-miniprogram'

export const store = observable({
  // 数据字段
  numA: 1,
  numB: 2,
  activeTabBarIndex: 0,

  
    // 修改 activeTabBarIndex
    updateActiveTabBarIndex: action(function (index) {
      this.activeTabBarIndex = index
    }),

  // 计算属性
  get sum() {
    return this.numA + this.numB
  },

  // actions 方法，用来修改 store 中的数据
  updateNumA: action(function (step) {
    this.numA += step
  }),

  updateNumB: action(function (step) {
    this.numB += step
  })
})